<?php

namespace app\admin\model;

use think\Db;

class OrderModel extends Model
{
    public function count()
    {
        $list = Db::table('order')->alias('a')->join('product b', 'a.pro_id = b.pro_no')->field('a.*,b.title')->select();
       // $list = Db::query('SELECT a.*,b.title from `order` a LEFT JOIN `product` b ON a.pro_no = b.pro_no');
        $list_length = count($list);
        return $list_length;
    }
    public function list($page, $limit)
    {
        return Db::table('order')->page($page, $limit)->select();
    }
    public function add($data)
    {
        return Db::table('order')->insert($data);
    }

    public function delete($id)
    {
        return Db::table('order')->where('id=' . $id)->delete();
    }

    public function like($order_no)
    {
        return Db::table('order')->where('order_no', 'like', $order_no . '%')->select();
    }
}